<template>
  <div>
    <div>
      <div style="text-align: center; margin: 10px">
        {{ form.TaskName }}
      </div>
      <div class="block-box">
        <div class="block-box_item">
          <eagle-cell-group :border="border">

            <eagle-input
              label="检查企业"
              autosize
              type="textarea"
              rows="1"
              v-if="form.CPID == null"
              :value="form.EnterpriseName"
              readonly
              islink
              @click="goFromDeta()"
            ></eagle-input>

            <eagle-input
              class="input_text"
              :value="form.CorrectiveDeptName"
              label="选择改派人"
              required
              readonly
              rows="1"
              islink
						@click="_goCheckTaskPeople()"
            >
						<template #right-icon><van-icon name="arrow" /></template>
           ></eagle-input>

            <!-- <van-field
              label="隐患描述"
              rows="3"
              autosize
              type="textarea"
              v-model="form.HiddenDangerDesc"
              readonly
            >
            </van-field> -->

          </eagle-cell-group> 
          <!-- <div class="fjcolor">
            <div class="borderbot">
              <div class="upload-hd">
                <span class="imglist">隐患附件</span>
                  <div class="imgs mr-10" v-for="(item, index) in fileList" :key="index">
                    <img class="upload-img" :src="baseUrl + item" />
                    
                  </div>
                
              </div>
            </div>
		      </div>	 -->
          
        </div>
      </div>
      
      <div class="btns m-10">
        <eagle-button style="flex:1;" type="green2"  @click="DeptReassignment()">转推</eagle-button>
      </div>

    </div>



    <Departmentuser
        :show.sync="DepartmentTypeShow"
        @callback="_userchoosePeople"
        :selectedValue="this.form.CorrectiveDeptCode"
        >
    </Departmentuser>


  </div>
</template>

<script>
import { getDateTime } from "@/utils/getDate";
import { mapGetters } from "vuex";
import Departmentuser from "../FeedSafetyProduction/userPeopleChooseDialog.vue";
export default {
  components: {
		Departmentuser,
	},
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      id: this.$route.query.id,
      isDate: true,
      border: false,
      DepartmentTypeShow: false,
      fileList :[],
      form: {
        Templates: [],
      },
    };
  },
  computed: {
    ...mapGetters(["CompanyCode"]),
  },
  created() {
    this.isDate = this.$route.query.isDate;
    this.geDetail();
  },
  methods: {
    // 上传图片
    goMyTaskFileList(imgType) {
      this.$router.push(
        "/OtherDanger/DangerCheckTaskFileList?ctCode=" + this.form.CTCode + "&type=" + imgType
      );
    },

    // 检查记录
    goMyTaskHistoryList() {
      this.$router.push({
        path: "/OtherDanger/CheckPlanHistoryList",
        query: {
          ctCode: this.form.CTCode,
        },
      });
    },

    // 待验收隐患
    goMyTaskyinhuan() {
        this.$router.push({
        path: "/OtherDanger/DangerCheckTaskDetailVerifyList",
        query: {
          ctCode: this.form.CTCode,
        },
      });
    },



    		// 选择部门
		_goCheckTaskPeople(backpath) {
			
			this.DepartmentTypeShow = true
		},
		// 选择部门回调
		_userchoosePeople(item) {
			if (item) {
				this.$set(this.form, 'CorrectiveDeptName', item.name)
				this.form.CorrectiveDeptCode = item.code

				this.DepartmentTypeShow = false
			}
		},

    // 获取详情
    geDetail() {
      let that = this;
      that.$axios
      .get("/ChsDangerNotPorduce/Edit/{id}",{params:{ id: that.id }})
      .then((res) => {
        that.form = res.data;
        that.form.StartDate = getDateTime(this.form.StartDate);
        that.form.EndDate = getDateTime(this.form.EndDate);
        that.form.CreateDate = getDateTime(this.form.CreateDate);
        				if (res.data.Attachs != null && res.data.Attachs != "") {
					this.fileList = res.data.Attachs.split(";");
				}
      });
    },

    // 企业信息详情
    goFromDeta() {
      this.$router.push("/BaseInfo?CompanyCode=" + this.form.EnterpriseCode);
    },

    // 转推提交
    DeptReassignment() {
      let that = this;
      let params = {
        id: that.id,
        CorrectiveDeptCode:that.form.CorrectiveDeptCode,
        CorrectiveDeptName:that.form.CorrectiveDeptName
      }
      let url = "/ChsDangerNotPorduce/TurnPushPost"
      that.$dialog.confirm({
        title: "询问",
        message: "您确定要转推当前检查任务吗?",
      })
        .then(() => {
          that.$axios
          .post(url,params)
          .then((res)=>{
            that.$toast.success("转推成功！");
            that.$router.goRefresh(-1);
          })
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="less" scoped>
/*
        .main {
            height: 100vh;
        }
    */
.bottom-btns {
  margin-top: 10px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .submit-btn {
    width: 32%;
    height: 35px;
    font-size: 14px;
  }
  .delete-btn {
    width: 100%;
    height: 35px;
    font-size: 14px;
  }
}
.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_riskunit_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 20px;
      width: 20px;
      margin-right: 5px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}

.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}
.text_box {
  padding: 10px;
  border-radius: 5px;
  /*background-color: #e8f1f8;*/
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_list {
  font-size: 12px;
  border: 1px solid #e8f1f8;
  .operate_row_first {
    padding: 10px;
    background-color: #e8f1f8;
    border-bottom: 1px solid #e8f1f8;
    margin-bottom: 10px;
  }
  .operate_row {
    padding: 10px;
    border-bottom: 1px solid #e8f1f8;
    /*margin-bottom: 10px;*/
  }
}
  .mls{
    margin-right: 5px;
  }
  .fjcolor {
	background-color: #fff;
}
.borderbot{
	border-bottom: 0.02667rem solid #ebedf0;
	margin: 0 15px;
}
.upload-hd {
	display: flex;
	padding-top: 10px;
	padding-bottom: 10px;
	.upload-img,
	.imgs {
		position: relative;
		width: 60px;
		height: 60px;
	}
	.delImg {
		position: absolute;
		top: -5px;
		right: -5px;
		width: 16px;
		height: 16px;
		img {
			width: 100%;
			height: 100%;
		}
	}
}
.imglist {
	font-size: 0.37333rem;
	color: #646566;
	margin-right: 1.7rem;
}
</style>
